using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using kxcxw.Data.Entities;

namespace kxcxw.Data.Mapping
{
	public class InformationReviewMap : EntityTypeConfiguration<InformationReview>
	{
		public InformationReviewMap()
		{
			// Primary Key
			this.HasKey(t => t.ReviewID);

			// Properties
			this.Property(t => t.ReviewID)
				.IsRequired()
				.HasMaxLength(36);
				
			this.Property(t => t.InformationID)
				.HasMaxLength(36);
				
			this.Property(t => t.NickName)
				.HasMaxLength(20);
				
			this.Property(t => t.ReViewContent)
				.HasMaxLength(400);
				
			this.Property(t => t.UserID)
				.HasMaxLength(36);
				
			// Table & Column Mappings
			this.ToTable("InformationReview");
			this.Property(t => t.ReviewID).HasColumnName("ReviewID");
			this.Property(t => t.InformationID).HasColumnName("InformationID");
			this.Property(t => t.NickName).HasColumnName("NickName");
			this.Property(t => t.CreateDate).HasColumnName("CreateDate");
			this.Property(t => t.ReViewContent).HasColumnName("ReViewContent");
			this.Property(t => t.UserID).HasColumnName("UserID");

			// Relationships
			this.HasOptional(t => t.PublichInformation)
				.WithMany(t => t.InformationReviews)
				.HasForeignKey(d => d.InformationID);
				
		}
	}
}

